public class Day05 {
    public static void main(String[] args) {
        Integer a = 1;
        Integer b = 1;
        System.out.println(a == b);
        Integer c = new Integer(1);
        Integer d = new Integer(1);
        System.out.println(c == d);
        System.out.println(a == c);
    }

    // 各位相加
    public int addDigits(int num) {
        int ret = num;
        while((ret = add(ret)) / 10 != 0);
        return ret;
    }

    private int add(int n) {
        int ret = 0;
        while(n != 0) {
            ret += n % 10;
            n /= 10;
        }
        return ret;
    }
    // 猜数字大小 guess() 题目已经提供
    public int guessNumber(int n) {
        int left = 1;
        int right = n;

        while(left <= right) {
            int mid = (right - left) / 2 + left;
            int flag = guess(mid);
            if(flag == 0) {
                return mid;
            } else if(flag < 0) {
                right = mid - 1;
            } else {
                left = mid + 1;
            }
        }

        return -1;
    }

    public int guess(int mid) {
        return 1;
    }
}
